﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Net.Mail;
using System.Net;

using SendGrid;

namespace CorreoSocialWeb
{
    public class SendGridMail
    {
        public static void Send(NetworkCredential credentials, string asunto, string destinatario, string mensaje)
        {
            credentials = new NetworkCredential("correosocial", "correosocial");

            MailMessage message = new MailMessage();
            
            var fromAddress = "noresponder@correosocial.com.ar";

            message.From = new MailAddress(fromAddress);

            message.To.Add(destinatario);

            message.Subject = asunto;

            message.Body = mensaje;

            SmtpClient client = new SmtpClient("smtp.sendgrid.net", 25);

            asunto += " " + DateTime.Now.ToString();

            //client.EnableSsl = true;
            client.Credentials = credentials;
            //client.Timeout = 1;

            client.Send(message);
        }
    }
}